package utils;

import android.app.Activity;
import android.content.Context;

import com.example.xuegengwang.xuegengwang.R;

import java.io.File;
import java.util.ArrayList;

import cn.qqtheme.framework.picker.AddressPicker;
import common.Constant;
import view.MyAddressPicker;
import view.MyOptionPicker;

/**
 * Created by Administrator on 2017/3/29.
 */

public class PickerUtils {
    private static MyAddressPicker picker;

    public static MyAddressPicker showAddressSelector(Context context) {
        ArrayList<MyAddressPicker.Province> province = AddressDbUtils.getProvince(context);//获取省市区
        picker = new MyAddressPicker((Activity) context, province);
        picker.setTopBackgroundColor(context.getResources().getColor(R.color.gray_back));
        picker.setLineColor(context.getResources().getColor(R.color.common_color));
        picker.setOffset(2);
        picker.setTextSize(16);
        picker.setLineColor(context.getResources().getColor(R.color.gray_back));
        picker.setTextColor(context.getResources().getColor(R.color.text_color));
        picker.setSubmitTextColor(context.getResources().getColor(R.color.common_color));
        picker.setSelectedItem(province.get(0).getAreaName(), province.get(0).getCities().get(0).getAreaName(), province.get(0).getCities().get(0).getCounties().get(0).getAreaName());
        picker.show();
//        DBUtils.deleteTable(ConsulterModel.class);
        FileUtils.getInstance().deleteDir(new File(Constant.VOLUNTEERS_DIR));//清志愿者列表
        return picker;
    }


    public static MyOptionPicker showSubjectSelector(Context context) {
        ArrayList<String> arrayList = new ArrayList<>();
        arrayList.add("文科");
        arrayList.add("理科");
        MyOptionPicker optionPicker = new MyOptionPicker((Activity) context, arrayList);
        optionPicker.setTextSize(16);
        optionPicker.setTopBackgroundColor(context.getResources().getColor(R.color.gray_back));
        optionPicker.setLineColor(context.getResources().getColor(R.color.common_color));
        optionPicker.setLineColor(context.getResources().getColor(R.color.gray_back));
        optionPicker.setTextColor(context.getResources().getColor(R.color.text_color));
        optionPicker.setSubmitTextColor(context.getResources().getColor(R.color.common_color));
        optionPicker.show();
        return optionPicker;
    }


    public static MyOptionPicker showSelector(Context context, ArrayList<String> arrayList) {
        if (arrayList != null) {
            if (arrayList.size() > 0) {
                MyOptionPicker optionPicker = new MyOptionPicker((Activity) context, arrayList);
                optionPicker.setTextSize(16);
                optionPicker.setTopBackgroundColor(context.getResources().getColor(R.color.gray_back));
                optionPicker.setLineColor(context.getResources().getColor(R.color.common_color));
                optionPicker.setLineColor(context.getResources().getColor(R.color.gray_back));
                optionPicker.setTextColor(context.getResources().getColor(R.color.text_color));
                optionPicker.setSubmitTextColor(context.getResources().getColor(R.color.common_color));
                optionPicker.show();
                return optionPicker;
            } else {
                return null;
            }
        } else {
            return null;
        }
    }

}
